package com.example.adminsystem.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("后台管理系统API文档")
                        .description("基于SpringBoot+MyBatis+MySQL的后台管理系统")
                        .version("1.0"))
                .components(new Components()
                        .addSecuritySchemes("OAuth2", 
                                new SecurityScheme()
                                        .type(SecurityScheme.Type.OAUTH2)
                                        .flows(new OAuthFlows()
                                                .password(new OAuthFlow()
                                                        .tokenUrl("/auth")
                                                        .scopes(new Scopes())))))
                .addSecurityItem(new SecurityRequirement().addList("OAuth2"));
    }
}
